package com.gite.nouette.admin.implementation.controller.module;

import java.util.List;

import com.gite.nouette.admin.contract.controller.module.ICModuleLog;
import com.gite.nouette.admin.contract.data.ILog;
import com.gite.nouette.admin.contract.model.module.IModuleLog;
import com.gite.nouette.admin.contract.service.ICallback;
import com.gite.nouette.admin.contract.view.module.IVModuleLog;
import com.gite.nouette.admin.implementation.controller.AbstractCModule;
import com.google.gwt.user.client.Window;

public class CModuleLogImpl extends AbstractCModule<IVModuleLog, IModuleLog>
		implements ICModuleLog {

	@Override
	public void getLogs(ICallback<List<ILog>> callback) {
		getM().getLogs(callback);
	}

	@Override
	public void init() {
		ICallback<List<ILog>> callback = new ICallback<List<ILog>>() {
			@Override
			public void onDone(List<ILog> result) {
				getV().setLogs(result);
			}

			@Override
			public void onError(Throwable throwable) {
				// TODO manage exception
				Window.alert(throwable.getMessage());
			}
		};
		getLogs(callback);
	}

}
